์ฝ๋
import folium
m = folium.Map()
mMake this Notebook Trusted to load map: File -> Trust Notebook
lazychoi
October 31, 2022
์๋, ๊ฒฝ๋ ๊ตฌํ๊ธฐ
์ง๋ ํ์ ์ต์
Marker(location=None, popup=None, tooltip=None, icon=None, draggable=False, **kwargs)
m = folium.Map(location=[37.46854308,126.88626333], zoom_start=10)
folium.Marker([37.46854308,126.88626333], icon=folium.Icon(color='red', icon='car', prefix='fa'), popup='<h1>๋
์ฐ</h1>', tooltip='๋
์ฐ').add_to(m)
folium.Marker([37.55277,126.98969], icon=folium.Icon(color='red', icon='home', prefix='fa'), tooltip='๋จ์ฐ').add_to(m)
folium.Marker([37.57101,126.89623], icon=folium.Icon(color='red', icon='car', prefix='fa'), tooltip='๋งํฌ').add_to(m)
folium.Marker([37.50721,126.76684], icon=folium.Icon(color='red', icon='car', prefix='fa'), tooltip='๋ถ์ฒ').add_to(m)
mm = folium.Map(location=[37.46854308,126.88626333], zoom_start=10)
folium.CircleMarker([37.46854308,126.88626333], radius=10, popup='<h1>๋
์ฐ</h1>', tooltip='10').add_to(m)
folium.CircleMarker([37.55277,126.98969], radius=30, tooltip='30').add_to(m)
folium.CircleMarker([37.57101,126.89623], radius=50, tooltip='50').add_to(m)
folium.CircleMarker([37.50721,126.76684], radius=70, tooltip='70').add_to(m)
m| ์๊ตฐ๋ช | ๋ฑ๋ก๋๋ฌผ์ | ๋ฑ๋ก์์ ์์ | ๊ด๊ณต์ | ์๋ | ๊ฒฝ๋ | ์ด์ธ๊ตฌ์ | 1000๋ช ๋น๋ง๋ฆฌ์ | 1์์ ์๋น๋ง๋ฆฌ์ | ํ๊ท ์ฐ๋ น | ๋จ์ํ๊ท ์ฐ๋ น | ์ฌ์ํ๊ท ์ฐ๋ น | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | ๊ฐํ๊ตฐ | 4017 | 2006.0 | ๊ฐํ๊ตฐ์ฒญ | 37.831318 | 127.509706 | 62168 | 64.62 | 2.00 | 50.3 | 49.1 | 51.6 |
| 1 | ๊ณ ์์ | 73477 | 54580.0 | ๊ณ ์์์ฒญ | 37.658422 | 126.831964 | 1079277 | 68.08 | 1.35 | 42.9 | 42.0 | 43.9 |
| 2 | ๊ณผ์ฒ์ | 2974 | 2325.0 | ๊ณผ์ฒ์์ฒญ | 37.429812 | 126.986963 | 78301 | 37.98 | 1.28 | 41.5 | 40.4 | 42.5 |
m = folium.Map(
location = [37.528043, 126.980238],
zoom_start = 8)
lat = list(df['์๋'])
long = list(df['๊ฒฝ๋'])
si = list(df['์๊ตฐ๋ช
'])
population = list(df['์ด์ธ๊ตฌ์'])
for i in range(len(lat)):
folium.Marker(
[lat[i], long[i]], tooltip=f'<b>{si[i]}</b><br>์ด์ธ๊ตฌ์: {str(population[i])}',
icon=folium.Icon(color='red')
).add_to(m)
m์ค์!! ๋ฐ์ดํฐ์ ํ์ ๊ตฌ์ญ๋ช ๊ณผ geojson ํ์ผ์ ํ์ ๊ตฌ์ญ๋ช ์ด ๊ฐ์์ผ ํจ
geojson ํ์ผ ๋ฐ์ ๊ณณ: ๋ํ๋ฏผ๊ตญ ํ์ ๋ ๊ฒฝ๊ณ ํ์ผ
geojson ๋ฐ์ดํฐ์ ๊ดํ ์ค๋ช
{
"type": "FeatureCollection",
"name": "20220701",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "OBJECTID": 1, "adm_nm": "์์ธํน๋ณ์ ์ข
๋ก๊ตฌ ์ฌ์ง๋", "adm_cd": "1101053", "adm_cd2": "1111053000", "sgg": "11110", "sido": "11", "sidonm": "์์ธํน๋ณ์", "sggnm": "์ข
๋ก๊ตฌ", "adm_cd8": "11010530" }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 126.976888842748167, 37.575650779448786 ], [ 126.977034498877501, 37.569194530054553 ], [ 126.975974728212492, 37.569336299425764 ], [ 126.975374709912543, 37.569315567021562 ], [ 126.974331935623255, 37.569261800517531 ], [ 126.969048370018541, 37.568194417708334 ], [ 126.968544936033837, 37.568427679612761 ], [ 126.966649959821197, 37.569491655206583 ], [ 126.966281750244846, 37.569700734798701 ], [ 126.966097327080405, 37.569856509723699 ], [ 126.965728529225771, 37.570183936115114 ], [ 126.965926998221278, 37.570318805686199 ], [ 126.96601094018429, 37.571548395577466 ], [ 126.963659220521961, 37.575174660660373 ], [ 126.963086004345101, 37.576485920015543 ], [ 126.962840990511978, 37.57666158609274 ], [ 126.962810410472628, 37.579448809656775 ], [ 126.967424315843317, 37.579601537124489 ], [ 126.967421763026508, 37.579263521441646 ], [ 126.967430060184597, 37.579192577998604 ], [ 126.967457090095607, 37.578975250585437 ], [ 126.968066046996256, 37.578246780467872 ], [ 126.968955116954774, 37.577935262340283 ], [ 126.969212842969057, 37.577935299309388 ], [ 126.969414538865792, 37.578121124142164 ], [ 126.969664426694706, 37.578531136682209 ], [ 126.969667219148718, 37.578736205134931 ], [ 126.969668773533087, 37.578992879009881 ], [ 126.969669499103631, 37.57911252674959 ], [ 126.969904573616262, 37.579301753628734 ], [ 126.97135197544759, 37.57951327793981 ], [ 126.973819257844539, 37.579372140302631 ], [ 126.973917363383421, 37.578487073041011 ], [ 126.973939619980882, 37.578240429978088 ], [ 126.974331538357575, 37.575749906299862 ], [ 126.975803789978045, 37.575649468824203 ], [ 126.976888842748167, 37.575650779448786 ] ] ] ] } },
]}
folium.LayerControl()์ ์์ด๋ ์๋์ ํ๋ค. ์ฌ๊ธฐ์๋ ๋นผ๋ ๋ ๊ฒ ๊ฐ๋ค.
import json
m = folium.Map(
location = [37.528043, 126.980238],
zoom_start = 8)
lat = list(df['์๋'])
long = list(df['๊ฒฝ๋'])
name = list(df['๋ฑ๋ก๋๋ฌผ์'])
si = list(df['์๊ตฐ๋ช
'])
for i in range(len(lat)):
folium.Marker(
[lat[i], long[i]], tooltip=f'<b>{si[i]}</b><br>๋ฐ๋ ค๋๋ฌผ์: {str(name[i])}',
icon=folium.Icon(color='red')
).add_to(m)
geo_data = json.load(open('data/HangJeongDong_ver20220701.geojson', encoding='UTF8'))
folium.Choropleth(
geo_data = geo_data,
data = df,
columns= ['์๊ตฐ๋ช
', '๋ฑ๋ก๋๋ฌผ์'],
key_on = 'feature.properties.sggnm',
fill_color = 'Reds',
fill_opacity = 0.7,
line_opacity = 0.4,
legend_name = '์๊ตฐ๋ณ ๋ฑ๋ก ๋ฐ๋ ค๋๋ฌผ์(๋ง๋ฆฌ))'
).add_to(m)
folium.LayerControl().add_to(m)
m